import './assets/main.css'

import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import App from './App.vue'
import routes from './router/index'
import axios from 'axios'

// 配置axios基础URL
axios.defaults.baseURL = 'http://localhost:8080'
axios.defaults.timeout = 10000

// 创建路由
const router = createRouter({
  history: createWebHistory(),
  routes
})

const app = createApp(App)

// 注册Element Plus图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 使用Element Plus并配置中文语言包
app.use(ElementPlus, {
  locale: zhCn,
})
app.use(router)
app.config.globalProperties.$http = axios

app.mount('#app')
